//+------------------------------------------------------------------+ //| CCFp_v1.0.2.mq4 | //| SemSemFX@rambler.ru | //| http://onix-trade.net/forum/index.php?showtopic=107 | //| Modifed version by Skyline on 09 Oct 2008 | //+------------------------------------------------------------------+ // Rev. v1.0.1 ** Added +/-/= symbols to show strength of last 2 closed candles // ** Added IBFX symbols management // Rev. v1.0.2 ** Fixed symbols paint issue whenever a new candle starts #property copyright "SemSemFX@rambler.ru" #property link "http://onix-trade.net/forum/index.php?showtopic=107" //---- extern string Indicator_ID = "CCFocv2:"; int Objs = 0; //---- #property indicator_separate_window #property indicator_buffers 8 extern bool USD = true; extern bool EUR = true; extern bool GBP = true; extern bool CHF = true; extern bool JPY = true; extern bool AUD = true; extern bool CAD = true; extern bool NZD = true; extern color Color_USD = Green; extern color Color_EUR = Aqua; extern color Color_GBP = Red; extern color Color_CHF = Chocolate; extern color Color_JPY = Maroon; extern color Color_AUD = DarkOrange; extern color Color_CAD = Purple; extern color Color_NZD = Teal; extern int Line_Thickness = 2; extern int All_Bars = 200; extern int Last_Bars = 0; extern int Y_Top = 14; extern int Y_Step = 15; extern int TxtSize = 10; //---- double arrUSD[]; double arrEUR[]; double arrGBP[]; double arrCHF[]; double arrJPY[]; double arrAUD[]; double arrCAD[]; double arrNZD[]; double myPoint; string Indicator_Name; string sAUDUSD,sEURUSD,sUSDCHF,sNZDUSD,sGBPUSD,sUSDJPY,sUSDCAD; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators Indicator_Name = Indicator_ID; IndicatorShortName(Indicator_Name); int width = 0; if(0 > StringFind(Symbol(), "USD", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(0, DRAW_LINE, DRAW_LINE, width, Color_USD); SetIndexBuffer(0, arrUSD); SetIndexLabel(0, "USD"); if(0 > StringFind(Symbol(), "EUR", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(1, DRAW_LINE, DRAW_LINE, width, Color_EUR); SetIndexBuffer(1, arrEUR); SetIndexLabel(1, "EUR"); if(0 > StringFind(Symbol(), "GBP", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(2, DRAW_LINE, DRAW_LINE, width, Color_GBP); SetIndexBuffer(2, arrGBP); SetIndexLabel(2, "GBP"); if(0 > StringFind(Symbol(), "CHF", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(3, DRAW_LINE, DRAW_LINE, width, Color_CHF); SetIndexBuffer(3, arrCHF); SetIndexLabel(3, "CHF"); if(0 > StringFind(Symbol(), "JPY", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(4, DRAW_LINE, DRAW_LINE, width, Color_JPY); SetIndexBuffer(4, arrJPY); SetIndexLabel(4, "JPY"); if(0 > StringFind(Symbol(), "AUD", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(5, DRAW_LINE, DRAW_LINE, width, Color_AUD); SetIndexBuffer(5, arrAUD); SetIndexLabel(5, "AUD"); if(0 > StringFind(Symbol(), "CAD", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(6, DRAW_LINE, DRAW_LINE, width, Color_CAD); SetIndexBuffer(6, arrCAD); SetIndexLabel(6, "CAD"); if(0 > StringFind(Symbol(), "NZD", 0)) width = 1; else width = Line_Thickness; SetIndexStyle(7, DRAW_LINE, DRAW_LINE, width, Color_NZD); SetIndexBuffer(7, arrNZD); SetIndexLabel(7, "NZD"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- for(int i = 0; i < Objs; i++) { if(!ObjectDelete(Indicator_Name + i)) Print("error: code #", GetLastError()); } //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { string AddChar; int limit; int counted_bars = IndicatorCounted(); //---- checking for possible errors if(counted_bars < 0) return(-1); //---- the last bar will be recounted if(All_Bars < 1) All_Bars = Bars; if(counted_bars > 0 && Last_Bars > 0) counted_bars -= Last_Bars; limit = All_Bars; //---- IBFX Changes // if (StringFind(Symbol(),"m") != -1) if (StringLen(Symbol()) == 7) { AddChar = StringSubstr(Symbol(), 6, 1); sAUDUSD = "AUDUSD" + AddChar; sEURUSD = "EURUSD" + AddChar; sUSDCHF = "USDCHF" + AddChar; sNZDUSD = "NZDUSD" + AddChar; sGBPUSD = "GBPUSD" + AddChar; sUSDJPY = "USDJPY" + AddChar; sUSDCAD = "USDCAD" + AddChar; } else { sAUDUSD = "AUDUSD"; sEURUSD = "EURUSD"; sUSDCHF = "USDCHF"; sNZDUSD = "NZDUSD"; sGBPUSD = "GBPUSD"; sUSDJPY = "USDJPY"; sUSDCAD = "USDCAD"; } //---- main cycle for(int i = 0; i < limit; i++) { GetOpenCloseCalcs(i); }//end block for(int i=0; iarrUSD[1]) sl("USD", arrUSD[1], arrUSD[2], "SymbUSD","-", cur, Color_USD); if (arrUSD[2]==arrUSD[1]) sl("USD", arrUSD[1], arrUSD[2], "SymbUSD","=", cur, Color_USD); cur += st; } if(EUR) { if (arrEUR[2]arrEUR[1]) sl("EUR", arrEUR[1], arrEUR[2], "SymbEUR","-", cur, Color_EUR); if (arrEUR[2]==arrEUR[1]) sl("EUR", arrEUR[1], arrEUR[2], "SymbEUR","=", cur, Color_EUR); cur += st; } if(GBP) { if (arrGBP[2]arrGBP[1]) sl("GBP", arrGBP[1], arrGBP[2], "SymbGBP","-", cur, Color_GBP); if (arrGBP[2]==arrGBP[1]) sl("GBP", arrGBP[1], arrGBP[2], "SymbGBP","=", cur, Color_GBP); cur += st; } if(CHF) { if (arrCHF[2]arrCHF[1]) sl("CHF", arrCHF[1], arrCHF[2], "SymbCHF","-", cur, Color_CHF); if (arrCHF[2]==arrCHF[1]) sl("CHF", arrCHF[1], arrCHF[2], "SymbCHF","=", cur, Color_CHF); cur += st; } if(AUD) { if (arrAUD[2]arrAUD[1]) sl("AUD", arrAUD[1], arrAUD[2], "SymbAUD","-", cur, Color_AUD); if (arrAUD[2]==arrAUD[1]) sl("AUD", arrAUD[1], arrAUD[2], "SymbAUD","=", cur, Color_AUD); cur += st; } if(CAD) { if (arrCAD[2]arrCAD[1]) sl("CAD", arrCAD[1], arrCAD[2], "SymbCAD","-", cur, Color_CAD); if (arrCAD[2]==arrCAD[1]) sl("CAD", arrCAD[1], arrCAD[2], "SymbCAD","=", cur, Color_CAD); cur += st; } if(JPY) { if (arrJPY[2]arrJPY[1]) sl("JPY", arrJPY[1], arrJPY[2], "SymbJPY","-", cur, Color_JPY); if (arrJPY[2]==arrJPY[1]) sl("JPY", arrJPY[1], arrJPY[2], "SymbJPY","=", cur, Color_JPY); cur += st; } if(NZD) { if (arrNZD[2]arrNZD[1]) sl("NZD", arrNZD[1], arrNZD[2], "SymbNZD","-", cur, Color_NZD); if (arrNZD[2]==arrNZD[1]) sl("NZD", arrNZD[1], arrNZD[2], "SymbNZD","=", cur, Color_NZD); cur += st; } } //+------------------------------------------------------------------+ //| Subroutines | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void sl(string currency, double val1, double val2, string IndicatoreName, string sym, int y, color col) { int window = WindowFind(Indicator_Name); string ID = Indicator_Name+Objs; string mIndicatoreName, disp; double diff; mIndicatoreName = Indicator_ID + IndicatoreName; int tmp = 10 + y; Objs++; diff = val1 - val2; // disp = currency + " " + sym + " " + DoubleToStr(diff*1000.0, 2); disp = currency + " " + sym + " " + DoubleToStr(val1,4) + " : " + DoubleToStr(val2, 4) + " : " + DoubleToStr(diff, 4); if (ObjectFind(mIndicatoreName)==-1) { if(ObjectCreate(mIndicatoreName, OBJ_LABEL, window, 0, 0)) { //ObjectDelete(ID); ObjectSet(mIndicatoreName, OBJPROP_XDISTANCE, 10); ObjectSet(mIndicatoreName, OBJPROP_YDISTANCE, y); ObjectSetText(mIndicatoreName, disp, TxtSize, "Arial Black", col); } } else { ObjectSet(mIndicatoreName, OBJPROP_XDISTANCE, 10); ObjectSet(mIndicatoreName, OBJPROP_YDISTANCE, y); ObjectSetText(mIndicatoreName, disp, TxtSize, "Arial Black", col); } /* if(ObjectCreate(ID, OBJ_LABEL, window, 0, 0)) { //ObjectDelete(ID); ObjectSet(ID, OBJPROP_XDISTANCE, y + 35); ObjectSet(ID, OBJPROP_YDISTANCE, 10); ObjectSetText(ID, sym, 15, "Arial Black", col); } */ } //+------------------------------------------------------------------+